<?php
declare (strict_types = 1);
namespace security;

use security\encoder\PasswordEncoder;

/**
 * 认证
 */
class AuthenticationManager {

    private UserDetailsService $userDetailsService;

    private PasswordEncoder $passwordEncoder;

    /**
     * Attempts to authenticate the passed Authentication object, returning a fully populated Authentication object (including granted authorities) if successful.
     */
    public function authenticate(Authentication $authentication): Authentication {
        // An AuthenticationManager must honour the following contract concerning exceptions:
        // A DisabledException must be thrown if an account is disabled and the AuthenticationManager can test for this state.
        // A LockedException must be thrown if an account is locked and the AuthenticationManager can test for account locking.
        // A BadCredentialsException must be thrown if incorrect credentials are presented. Whilst the above exceptions are optional, an AuthenticationManager must always test credentials.
        // Exceptions should be tested for and if applicable thrown in the order expressed above (i.e. if an account is disabled or locked, the authentication request is immediately rejected and the credentials testing process is not performed). This prevents credentials being tested against disabled or locked accounts.
        return $authentication;
    }
}